import uiautomator2 as u2
from zz import zz_log, zz_code, zz_img, zz_str
from PIL import Image

log = zz_log.of()

# 图片匹配工具

if __name__ == '__main__':
    src_path = 'F:\_download\image.png'
    img_src = None
    if zz_str.is_null_or_empty(src_path):
        d = u2.connect(zz_code.env('DEVICE_ID'))
        img_src = d.screenshot()  # 截屏
    else:
        img_src = Image.open(src_path)
    target_path = './game/img/植物大战僵尸/play_sun01.png'  # 例子
    target_path = "./game/img/search_go.png"

    zz_img.find_img_rectangle(img_src, Image.open(target_path))
    # print(zz_img.find_img(img_src, Image.open(target_path)).to_json())
